package com.examination.system.administrator.controller;

import com.examination.api.administrator.CollegeMajorClassificationControllerApi;
import com.examination.framework.model.response.ResponseResult;
import com.examination.system.administration.CollegeMajorClassification;
import com.examination.system.administration.ext.CollegeMajorClassificationNode;

import com.examination.system.administration.response.AddAdministrationResult;
import com.examination.system.administration.response.DeleteAdministrationResult;
import com.examination.system.administrator.service.CollegeMajorClassificationService;
import com.mongodb.bulk.DeleteRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 寇淇芮
 * @Date 2019/8/18 12:48
 */
@RestController
@RequestMapping(value = "/administrator")
public class CollegeMajorClassificationController implements CollegeMajorClassificationControllerApi {
    @Autowired
    private CollegeMajorClassificationService collegeMajorClassificationService;

    @Override
    @PostMapping("/collegeMajorClassification/add/{id}")
    public AddAdministrationResult addCollegeMajorClassification(@PathVariable(value = "id") String id,
                                                                 @RequestBody CollegeMajorClassification collegeMajorClassification) {
        return collegeMajorClassificationService.addCollegeMajorClassification(id,collegeMajorClassification);
    }

    @Override
    @GetMapping("/collegeMajorClassification/list")
    public List<CollegeMajorClassificationNode> findCollegeMajorClassificationList() {
        return collegeMajorClassificationService.findCollegeMajorClassificationList();
    }

    /**
     * 修改数据
     * @param id
     * @param collegeMajorClassification
     * @return
     */
    @Override
    @PostMapping("/collegeMajorClassification/edit/{id}")
    public ResponseResult editCollegeMajorClassificationById(@PathVariable(value = "id") String id,
                                                             @RequestBody CollegeMajorClassification collegeMajorClassification) {
        return collegeMajorClassificationService.editCollegeMajorClassificationById(id,collegeMajorClassification);
    }

    @Override
    @DeleteMapping("/collegeMajorClassification/remove/{id}")
    public DeleteAdministrationResult removeCollegeMajorClassification(@PathVariable(value = "id") String id){
       return collegeMajorClassificationService.removeCollegeMajorClassification(id);
    }
}
